<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
  <meta charset="UTF-8">
  <title></title>
  <th:block th:include="common/pub_head :: default"></th:block>
  <th:block th:include="common/pub_head :: layui"></th:block>
</head>
<body class="container" style="padding: 4px 5px">
<form class="layui-form layui-form-pane" id="list_form">
  <input type="hidden" name="id" id="id" th:value="${pcBean.id}" />
  <input type="hidden" name="mac" id="mac" th:value="${pcBean.mac}" />
  <input type="hidden" name="createTime" id="createTime"
         th:value="${#dates.format(pcBean.createTime, 'yyyy-MM-dd HH:mm:ss')}" />
  <input type="hidden" name="status" id="status" th:value="${pcBean.status}" />
  <div class="layui-form-item">
    <div class="layui-form-inline">
      <label class="layui-form-label">登记IP<span class="f-red">*</span></label>
      <div class="layui-input-inline">
        <input type="text" name="ip" id="ip" lay-verify="required" placeholder="请输入登记IP"
               th:value="${pcBean.ip}"
               autocomplete="off" class="layui-input">
      </div>
    </div>
    <div class="layui-form-inline">
      <label class="layui-form-label">实际IP<span class="f-red">*</span></label>
      <div class="layui-input-inline">
        <input type="text" name="realIp" id="realIp" lay-verify="required"
               th:value="${pcBean.realIp}"
               placeholder="请输入实际IP" autocomplete="off" class="layui-input">
      </div>
    </div>
  </div>
  <div class="layui-form-item">
    <label class="layui-form-label">地址<span class="f-red">*</span></label>
    <div class="layui-input-block">
      <input type="text" lay-verify="required" placeholder="请输入地址"
             name="address" id="address"
             th:value="${pcBean.address}"
             autocomplete="off" class="layui-input">
    </div>
  </div>
  <div class="layui-form-item layui-form-text">
    <label class="layui-form-label">备注<span class="f-red">*</span></label>
    <div class="layui-input-block">
      <textarea placeholder="请输入备注" name="remark" id="remark"
                th:text="${pcBean.remark}" lay-verify="required"
                class="layui-textarea"></textarea>
    </div>
  </div>
  <div class="layui-form-item" style="position: absolute;right: 10px;top: 10px">
    <button type="button" class="layui-btn layui-btn-sm layui-btn-primary" onclick="resetForm()">重置</button>
    <button type="button" lay-submit="" lay-filter="save" class="layui-btn layui-btn-sm">保存</button>
  </div>
</form>
<script>
  /*<![CDATA[*/
  var form;
  layui.use(['table', 'form'], function () {
    form = layui.form;

    form.on('submit(save)', function (data) {
      saveAndFlushPc();
    });
  });

  function saveAndFlushPc() {
    var URL = path + "/pc/saveAndFlushPc";
    var formData = $("#list_form").serializeArray();

    var load = layer.load();
    $.post(URL, formData, function (jsonData) {
      layer.close(load);
      if (jsonData.flag) {
        layer.msg("保存成功", {icon: 1});
        window.parent.pagePc();
        setTimeout(function () {
          window.parent.layer.closeAll();
        }, 500);
      } else {
        layer.msg("保存失败", {icon: 2});
      }
    }, "json")
  }

  function resetForm() {
    $("#list_form")[0].reset();
  }

  /*]]>*/
</script>
</body>
</html>